Skip to content

Conversation

@copperpixel
Copy link
Contributor

@copperpixel copperpixel commented Dec 2, 2025

Description

CClientShadowMgr::ComputeExtraClipPlanes builds clip planes from the shadow bounding box corner farthest along the shadow direction to prevent dynamic shadows poking through surfaces.

If that corner ends up inside or goes through a brush it would cause the shadow to render on the other side of the brush's surface. This can happen when a model stands near a thin brush wall.

To fix this, this PR updates the compute routine to do a trace from the renderable's origin to the bounding box corner and push the corner's origin along the surface normal away from the brush towards the renderable if needed.

Note that this doesn't address the lack of dynamic shadow clipping through walls in the shadow direction because of the engine's hard-coded limit of max 4 clip planes per shadow. If the limit were to be incremented by 3 (1 plane for each axis) it would suffice to provide a fix for that.

Comparison screenshots of some problematic spots on Dustbowl:

Before After
rttshadow_clipping_fix_dustbowl1_before rttshadow_clipping_fix_dustbowl1_after
rttshadow_clipping_fix_dustbowl2_before rttshadow_clipping_fix_dustbowl2_after
rttshadow_clipping_fix_dustbowl3_before rttshadow_clipping_fix_dustbowl3_after
rttshadow_clipping_fix_dustbowl4_before rttshadow_clipping_fix_dustbowl4_after

Closes ValveSoftware/Source-1-Games#52

@SirYodaJedi
Copy link

SirYodaJedi commented Dec 3, 2025

Note that this doesn't address lack of dynamic shadow clipping oriented towards the shadow direction so it doesn't bleed through walls there because of the engine's hard-coded limit of max 4 clip planes per shadow.

I presume, in layman's terms, this means that improper shadows which are in the direction of the shadow will still appear, like so?

With shadows Shadows disabled
withshadows noshadows

(note shadows at crosshair)

@copperpixel
Copy link
Contributor Author

copperpixel commented Dec 3, 2025

Replying to #1686 (comment)

Yes.

Though if Valve were to raise the limit of clip planes it would've been possible to fix this a similar way to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TF2] Shadows seen through the wall

3 participants